package cn.chinaflame.pagodas.pool;

import static cn.chinaflame.pagodas.constant.Sysconst.POSITIONS;
import static cn.chinaflame.pagodas.pool.ThreadPool.CHECKPOOL;
import static cn.chinaflame.pagodas.pool.ThreadPool.CLEARPOOL;
import static cn.chinaflame.pagodas.pool.ThreadPool.SEARCHPOOL;
import static cn.chinaflame.pagodas.pool.ThreadPool.SENDPOOL;
import static cn.chinaflame.pagodas.utils.LightAlgo.LightUtil.*;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;

import cn.chinaflame.pagodas.service.WrmNIService;
import cn.chinaflame.pagodas.utils.LightAlgo.LightOp;
import cn.chinaflame.pagodas.utils.LightAlgo.Pillars;
import cn.chinaflame.pagodas.vo.LightVO;
/**
 * 
 * @author pengcheng.zhao
 *
 */
@Component
public class LightDispatcher {
	
	private static final Logger logger = LoggerFactory.getLogger(LightDispatcher.class);
	private static final long timeout = 600;//请示硬件操作灯位接口超时时间为600秒，即10分钟
	/**
	 * 批量检查灯位接口
	 * @param lightvo
	 * @return
	 */
	public List<LightVO> lightCheck(String lightnos){
		logger.info("lightnos:{}",lightnos);
		List<LightVO> result = Lists.newArrayList();
		 filterCheckLight(lightnos);
		Iterator<ArrayList<String>> it = CHECKLIGHTS.iterator();
		try {
			while(it.hasNext()) {
				ArrayList<String> lights = it.next();
				if(lights != null && lights.size() > 0) {
					LightTask lighttask =  new LightTask(lights,LightOp.lightCheck);
					Future<List<LightVO>> futureTask = CHECKPOOL.submit(lighttask);
					List<LightVO> future = futureTask.get(timeout, TimeUnit.SECONDS);
					result.addAll(future);
				}
			}
		} catch (InterruptedException | ExecutionException | TimeoutException e) {
			logger.error(e.getMessage());
		}finally {
//			if(!CHECKPOOL.isShutdown())
//				CHECKPOOL.shutdown();
		}
		logger.info("result:{}",result);
		   return result;
	}
	/**
	 * 调用点灯寻灯接口
	 * @param lightvo
	 * @return
	 */
/*	public List<LightVO> lightCheckAndSend(String lightvo){
		Iterator<ArrayList<String>> it = LIGHTS.iterator();
		ArrayList<String> lights = it.next();
		while(it.hasNext()) {
			CHECKPOOL.submit(new LightTask());
		}
	}*/
	/**
	 * 调用批量点灯接口
	 * @param lightvo
	 * @return
	 */
	public List<LightVO> lightSend(JSONArray lightvos){
		logger.info("lightvos:{}",lightvos);
		List<LightVO> result = Lists.newArrayList();
		filterSendLight(lightvos);
		Iterator<JSONArray> it = SENDLIGHTS.iterator();
		try {
			while(it.hasNext()) {
				JSONArray lights = it.next();
				if(lights != null && lights.size() > 0) {
					LightTask lighttask =  new LightTask(lights,LightOp.lightSend);
					Future<List<LightVO>> futureTask = SENDPOOL.submit(lighttask);
					List<LightVO> future = futureTask.get(timeout, TimeUnit.SECONDS);
					result.addAll(future);
				}
			}
		} catch (InterruptedException | ExecutionException | TimeoutException e) {
			logger.error(e.getMessage());
		}finally {
//			if(!SENDPOOL.isShutdown())
//				SENDPOOL.shutdown();
		}
		logger.info("result:{}",result);
	   return result;
	}
	/**
	 * 批量清灯接口
	 * @param lightvo
	 * @return
	 */
	public List<LightVO> lightClear(String lightnos){
		logger.info("lightnos:{}",lightnos);
		List<LightVO> result = Lists.newArrayList();
		filterClearLight(lightnos);
		Iterator<ArrayList<String>> it = CLEARLIGHTS.iterator();
		try {
			while(it.hasNext()) {
				ArrayList<String> lights = it.next();
				if(lights != null && lights.size() > 0) {
					LightTask lighttask =  new LightTask(lights,LightOp.lightClear);
					Future<List<LightVO>> futureTask = CLEARPOOL.submit(lighttask);
					List<LightVO> future = futureTask.get(timeout, TimeUnit.SECONDS);
					result.addAll(future);
				}
			}
		} catch (InterruptedException | ExecutionException | TimeoutException e) {
			logger.error(e.getMessage());
		}finally {
//			if(!CLEARPOOL.isShutdown())
//				CLEARPOOL.shutdown();
		}
		logger.info("result:{}",result);
	   return result;
	}
	/**
	 * 调用批量寻灯，执行闪烁操作
	 * @param lightvo
	 */
	public List<LightVO> lightSearch(String lightnos){
		logger.info("lightnos:{}",lightnos);
		List<LightVO> result = Lists.newArrayList();
		filterSearchLight(lightnos);
		Iterator<ArrayList<String>> it = SEARCHLIGHTS.iterator();
		try {
			while(it.hasNext()) {
				ArrayList<String> lights = it.next();
				if(lights != null && lights.size() > 0) {
					LightTask lighttask =  new LightTask(lights,LightOp.lightSearch);
					Future<List<LightVO>> futureTask = SEARCHPOOL.submit(lighttask);
					List<LightVO> future = futureTask.get(timeout, TimeUnit.SECONDS);
					result.addAll(future);
				}
			}
		} catch (InterruptedException | ExecutionException | TimeoutException e) {
			logger.error(e.getMessage());
		}finally {
//			if(!SEARCHPOOL.isShutdown())
//				SEARCHPOOL.shutdown();
		}
		logger.info("result:{}",result);
		return result;
	}
	
	/**
	 * 根据灯号所在柱号分到不同的灯列表中
	 * 分配寻灯位light到50个list
	 * @param light
	 */
    public static void filterSearchLight(String lights) {
    	logger.info("filterSearchLight:lights:{}",lights);
    	logger.info("POSITIONS.size()="+POSITIONS.size());
    	String[] lightarray = lights.split(",");
    	for(String light:lightarray) {
    		logger.info("light="+light);
		    	String no = light.substring(4, 6);
		    	Pillars pillars = Pillars.getByPillarNo(no);
		    	switch(pillars) {
		    	case P1:
		    		SEARCHLIGHTS1.add(light);
		    		break;
		    	case P2:
		    		SEARCHLIGHTS2.add(light);
		    		break;
		    	case P3:
		    		SEARCHLIGHTS3.add(light);
		    		break;
		    	case P4:
		    		SEARCHLIGHTS4.add(light);
		    		break;
		    	case P5:
		    		SEARCHLIGHTS5.add(light);
		    		break;
		    	case P6:
		    		SEARCHLIGHTS6.add(light);
		    		break;
		    	case P7:
		    		SEARCHLIGHTS7.add(light);
		    		break;
		    	case P8:
		    		SEARCHLIGHTS8.add(light);
		    		break;
		    	case P9:
		    		SEARCHLIGHTS9.add(light);
		    		break;
		    	case P10:
		    		SEARCHLIGHTS10.add(light);
		    		break;
		    	case P11:
		    		SEARCHLIGHTS11.add(light);
		    		break;
		    	case P12:
		    		SEARCHLIGHTS12.add(light);
		    		break;
		    	case P13:
		    		SEARCHLIGHTS13.add(light);
		    		break;
		    	case P14:
		    		SEARCHLIGHTS14.add(light);
		    		break;
		    	case P15:
		    		SEARCHLIGHTS15.add(light);
		    		break;
		    	case P16:
		    		SEARCHLIGHTS16.add(light);
		    		break;
		    	case P17:
		    		SEARCHLIGHTS17.add(light);
		    		break;
		    	case P18:
		    		SEARCHLIGHTS18.add(light);
		    		break;
		    	case P19:
		    		SEARCHLIGHTS19.add(light);
		    		break;
		    	case P20:
		    		SEARCHLIGHTS20.add(light);
		    		break;
		    	case P21:
		    		SEARCHLIGHTS21.add(light);
		    		break;
		    	case P22:
		    		SEARCHLIGHTS22.add(light);
		    		break;
		    	case P23:
		    		SEARCHLIGHTS23.add(light);
		    		break;
		    	case P24:
		    		SEARCHLIGHTS24.add(light);
		    		break;
		    	case P25:
		    		SEARCHLIGHTS25.add(light);
		    		break;
		    	case P26:
		    		SEARCHLIGHTS26.add(light);
		    		break;
		    	case P27:
		    		SEARCHLIGHTS27.add(light);
		    		break;
		    	case P28:
		    		SEARCHLIGHTS28.add(light);
		    		break;
		    	case P29:
		    		SEARCHLIGHTS29.add(light);
		    		break;
		    	case P30:
		    		SEARCHLIGHTS30.add(light);
		    		break;
		    	case P31:
		    		SEARCHLIGHTS31.add(light);
		    		break;
		    	case P32:
		    		SEARCHLIGHTS32.add(light);
		    		break;
		    	case P33:
		    		SEARCHLIGHTS33.add(light);
		    		break;
		    	case P34:
		    		SEARCHLIGHTS34.add(light);
		    		break;
		    	case P35:
		    		SEARCHLIGHTS35.add(light);
		    		break;
		    	case P36:
		    		SEARCHLIGHTS36.add(light);
		    		break;
		    	case P37:
		    		SEARCHLIGHTS37.add(light);
		    		break;
		    	case P38:
		    		SEARCHLIGHTS38.add(light);
		    		break;
		    	case P39:
		    		SEARCHLIGHTS39.add(light);
		    		break;
		    	case P40:
		    		SEARCHLIGHTS40.add(light);
		    		break;
		    	case P41:
		    		SEARCHLIGHTS41.add(light);
		    		break;
		    	case P42:
		    		SEARCHLIGHTS42.add(light);
		    		break;
		    	case P43:
		    		SEARCHLIGHTS43.add(light);
		    		break;
		    	case P44:
		    		SEARCHLIGHTS44.add(light);
		    		break;
		    	case P45:
		    		SEARCHLIGHTS45.add(light);
		    		break;
		    	case P46:
		    		SEARCHLIGHTS46.add(light);
		    		break;
		    	case P47:
		    		SEARCHLIGHTS47.add(light);
		    		break;
		    	case P48:
		    		SEARCHLIGHTS48.add(light);
		    		break;
		    	case P49:
		    		SEARCHLIGHTS49.add(light);
		    		break;
		    	case P50:
		    		SEARCHLIGHTS50.add(light);
		    		break;
		    		default:break;
		    	}
    	}
    }
    
    /**
     * 分配安装灯位light到50个list
     * @param light
     */
    public static void filterSendLight(JSONArray lightvos) {
    	logger.info("filterSendLight:lightvos:{}",lightvos);
//    	int positoncounts = POSITIONS.size();
    	logger.info("POSITIONS.size()="+POSITIONS.size());
    	for(int i = 0; i<lightvos.size();i++) {
    		JSONObject obj = lightvos.getJSONObject(i);
    		String light = obj.getString("lightno");
	    	String no = light.substring(4, 6);
	    	Pillars pillars = Pillars.getByPillarNo(no);
	    	switch(pillars) {
		    	case P1:
		    		SENDLIGHTS1.add(obj);
		    		break;
		    	case P2:
		    		SENDLIGHTS2.add(obj);
		    		break;
		    	case P3:
		    		SENDLIGHTS3.add(obj);
		    		break;
		    	case P4:
		    		SENDLIGHTS4.add(obj);
		    		break;
		    	case P5:
		    		SENDLIGHTS5.add(obj);
		    		break;
		    	case P6:
		    		SENDLIGHTS6.add(obj);
		    		break;
		    	case P7:
		    		SENDLIGHTS7.add(obj);
		    		break;
		    	case P8:
		    		SENDLIGHTS8.add(obj);
		    		break;
		    	case P9:
		    		SENDLIGHTS9.add(obj);
		    		break;
		    	case P10:
		    		SENDLIGHTS10.add(obj);
		    		break;
		    	case P11:
		    		SENDLIGHTS11.add(obj);
		    		break;
		    	case P12:
		    		SENDLIGHTS12.add(obj);
		    		break;
		    	case P13:
		    		SENDLIGHTS13.add(obj);
		    		break;
		    	case P14:
		    		SENDLIGHTS14.add(obj);
		    		break;
		    	case P15:
		    		SENDLIGHTS15.add(obj);
		    		break;
		    	case P16:
		    		SENDLIGHTS16.add(obj);
		    		break;
		    	case P17:
		    		SENDLIGHTS17.add(obj);
		    		break;
		    	case P18:
		    		SENDLIGHTS18.add(obj);
		    		break;
		    	case P19:
		    		SENDLIGHTS19.add(obj);
		    		break;
		    	case P20:
		    		SENDLIGHTS20.add(obj);
		    		break;
		    	case P21:
		    		SENDLIGHTS21.add(obj);
		    		break;
		    	case P22:
		    		SENDLIGHTS22.add(obj);
		    		break;
		    	case P23:
		    		SENDLIGHTS23.add(obj);
		    		break;
		    	case P24:
		    		SENDLIGHTS24.add(obj);
		    		break;
		    	case P25:
		    		SENDLIGHTS25.add(obj);
		    		break;
		    	case P26:
		    		SENDLIGHTS26.add(obj);
		    		break;
		    	case P27:
		    		SENDLIGHTS27.add(obj);
		    		break;
		    	case P28:
		    		SENDLIGHTS28.add(obj);
		    		break;
		    	case P29:
		    		SENDLIGHTS29.add(obj);
		    		break;
		    	case P30:
		    		SENDLIGHTS30.add(obj);
		    		break;
		    	case P31:
		    		SENDLIGHTS31.add(obj);
		    		break;
		    	case P32:
		    		SENDLIGHTS32.add(obj);
		    		break;
		    	case P33:
		    		SENDLIGHTS33.add(obj);
		    		break;
		    	case P34:
		    		SENDLIGHTS34.add(obj);
		    		break;
		    	case P35:
		    		SENDLIGHTS35.add(obj);
		    		break;
		    	case P36:
		    		SENDLIGHTS36.add(obj);
		    		break;
		    	case P37:
		    		SENDLIGHTS37.add(obj);
		    		break;
		    	case P38:
		    		SENDLIGHTS38.add(obj);
		    		break;
		    	case P39:
		    		SENDLIGHTS39.add(obj);
		    		break;
		    	case P40:
		    		SENDLIGHTS40.add(obj);
		    		break;
		    	case P41:
		    		SENDLIGHTS41.add(obj);
		    		break;
		    	case P42:
		    		SENDLIGHTS42.add(obj);
		    		break;
		    	case P43:
		    		SENDLIGHTS43.add(obj);
		    		break;
		    	case P44:
		    		SENDLIGHTS44.add(obj);
		    		break;
		    	case P45:
		    		SENDLIGHTS45.add(obj);
		    		break;
		    	case P46:
		    		SENDLIGHTS46.add(obj);
		    		break;
		    	case P47:
		    		SENDLIGHTS47.add(obj);
		    		break;
		    	case P48:
		    		SENDLIGHTS48.add(obj);
		    		break;
		    	case P49:
		    		SENDLIGHTS49.add(obj);
		    		break;
		    	case P50:
		    		SENDLIGHTS50.add(obj);
		    		break;
		    		default:break;
		    	}
    	}
    }
    /**
     * 分配检查灯位light到50个list
     * @param light
     */
    public static void filterCheckLight(String lights) {
    	logger.info("filterCheckLight:lights{}",lights);
//    	int positoncounts = POSITIONS.size();
    	logger.info("POSITIONS.size()="+POSITIONS.size());
    	String[] lightarray = lights.split(",");
    	for(String light:lightarray) {
		    	String no = light.substring(4, 6);
		    	Pillars pillars = Pillars.getByPillarNo(no);
		    	switch(pillars) {
		    	case P1:
		    		CHECKLIGHTS1.add(light);
		    		break;
		    	case P2:
		    		CHECKLIGHTS2.add(light);
		    		break;
		    	case P3:
		    		CHECKLIGHTS3.add(light);
		    		break;
		    	case P4:
		    		CHECKLIGHTS4.add(light);
		    		break;
		    	case P5:
		    		CHECKLIGHTS5.add(light);
		    		break;
		    	case P6:
		    		CHECKLIGHTS6.add(light);
		    		break;
		    	case P7:
		    		CHECKLIGHTS7.add(light);
		    		break;
		    	case P8:
		    		CHECKLIGHTS8.add(light);
		    		break;
		    	case P9:
		    		CHECKLIGHTS9.add(light);
		    		break;
		    	case P10:
		    		CHECKLIGHTS10.add(light);
		    		break;
		    	case P11:
		    		CHECKLIGHTS11.add(light);
		    		break;
		    	case P12:
		    		CHECKLIGHTS12.add(light);
		    		break;
		    	case P13:
		    		CHECKLIGHTS13.add(light);
		    		break;
		    	case P14:
		    		CHECKLIGHTS14.add(light);
		    		break;
		    	case P15:
		    		CHECKLIGHTS15.add(light);
		    		break;
		    	case P16:
		    		CHECKLIGHTS16.add(light);
		    		break;
		    	case P17:
		    		CHECKLIGHTS17.add(light);
		    		break;
		    	case P18:
		    		CHECKLIGHTS18.add(light);
		    		break;
		    	case P19:
		    		CHECKLIGHTS19.add(light);
		    		break;
		    	case P20:
		    		CHECKLIGHTS20.add(light);
		    		break;
		    	case P21:
		    		CHECKLIGHTS21.add(light);
		    		break;
		    	case P22:
		    		CHECKLIGHTS22.add(light);
		    		break;
		    	case P23:
		    		CHECKLIGHTS23.add(light);
		    		break;
		    	case P24:
		    		CHECKLIGHTS24.add(light);
		    		break;
		    	case P25:
		    		CHECKLIGHTS25.add(light);
		    		break;
		    	case P26:
		    		CHECKLIGHTS26.add(light);
		    		break;
		    	case P27:
		    		CHECKLIGHTS27.add(light);
		    		break;
		    	case P28:
		    		CHECKLIGHTS28.add(light);
		    		break;
		    	case P29:
		    		CHECKLIGHTS29.add(light);
		    		break;
		    	case P30:
		    		CHECKLIGHTS30.add(light);
		    		break;
		    	case P31:
		    		CHECKLIGHTS31.add(light);
		    		break;
		    	case P32:
		    		CHECKLIGHTS32.add(light);
		    		break;
		    	case P33:
		    		CHECKLIGHTS33.add(light);
		    		break;
		    	case P34:
		    		CHECKLIGHTS34.add(light);
		    		break;
		    	case P35:
		    		CHECKLIGHTS35.add(light);
		    		break;
		    	case P36:
		    		CHECKLIGHTS36.add(light);
		    		break;
		    	case P37:
		    		CHECKLIGHTS37.add(light);
		    		break;
		    	case P38:
		    		CHECKLIGHTS38.add(light);
		    		break;
		    	case P39:
		    		CHECKLIGHTS39.add(light);
		    		break;
		    	case P40:
		    		CHECKLIGHTS40.add(light);
		    		break;
		    	case P41:
		    		CHECKLIGHTS41.add(light);
		    		break;
		    	case P42:
		    		CHECKLIGHTS42.add(light);
		    		break;
		    	case P43:
		    		CHECKLIGHTS43.add(light);
		    		break;
		    	case P44:
		    		CHECKLIGHTS44.add(light);
		    		break;
		    	case P45:
		    		CHECKLIGHTS45.add(light);
		    		break;
		    	case P46:
		    		CHECKLIGHTS46.add(light);
		    		break;
		    	case P47:
		    		CHECKLIGHTS47.add(light);
		    		break;
		    	case P48:
		    		CHECKLIGHTS48.add(light);
		    		break;
		    	case P49:
		    		CHECKLIGHTS49.add(light);
		    		break;
		    	case P50:
		    		CHECKLIGHTS50.add(light);
		    		break;
		    		default:break;
		    	}
    	}
    }
    
    /**
     * 分配清灯位light到50个list
     * @param light
     */
    public static void filterClearLight(String lights) {
    	logger.info("filterClearLight:lights{}",lights);
//    	int positoncounts = POSITIONS.size();
    	logger.info("POSITIONS.size()="+POSITIONS.size());
    	String[] lightarray = lights.split(",");
    	for(String light:lightarray) {
		    	String no = light.substring(4, 6);
		    	Pillars pillars = Pillars.getByPillarNo(no);
		    	switch(pillars) {
		    	case P1:
		    		CLEARLIGHTS1.add(light);
		    		break;
		    	case P2:
		    		CLEARLIGHTS2.add(light);
		    		break;
		    	case P3:
		    		CLEARLIGHTS3.add(light);
		    		break;
		    	case P4:
		    		CLEARLIGHTS4.add(light);
		    		break;
		    	case P5:
		    		CLEARLIGHTS5.add(light);
		    		break;
		    	case P6:
		    		CLEARLIGHTS6.add(light);
		    		break;
		    	case P7:
		    		CLEARLIGHTS7.add(light);
		    		break;
		    	case P8:
		    		CLEARLIGHTS8.add(light);
		    		break;
		    	case P9:
		    		CLEARLIGHTS9.add(light);
		    		break;
		    	case P10:
		    		CLEARLIGHTS10.add(light);
		    		break;
		    	case P11:
		    		CLEARLIGHTS11.add(light);
		    		break;
		    	case P12:
		    		CLEARLIGHTS12.add(light);
		    		break;
		    	case P13:
		    		CLEARLIGHTS13.add(light);
		    		break;
		    	case P14:
		    		CLEARLIGHTS14.add(light);
		    		break;
		    	case P15:
		    		CLEARLIGHTS15.add(light);
		    		break;
		    	case P16:
		    		CLEARLIGHTS16.add(light);
		    		break;
		    	case P17:
		    		CLEARLIGHTS17.add(light);
		    		break;
		    	case P18:
		    		CLEARLIGHTS18.add(light);
		    		break;
		    	case P19:
		    		CLEARLIGHTS19.add(light);
		    		break;
		    	case P20:
		    		CLEARLIGHTS20.add(light);
		    		break;
		    	case P21:
		    		CLEARLIGHTS21.add(light);
		    		break;
		    	case P22:
		    		CLEARLIGHTS22.add(light);
		    		break;
		    	case P23:
		    		CLEARLIGHTS23.add(light);
		    		break;
		    	case P24:
		    		CLEARLIGHTS24.add(light);
		    		break;
		    	case P25:
		    		CLEARLIGHTS25.add(light);
		    		break;
		    	case P26:
		    		CLEARLIGHTS26.add(light);
		    		break;
		    	case P27:
		    		CLEARLIGHTS27.add(light);
		    		break;
		    	case P28:
		    		CLEARLIGHTS28.add(light);
		    		break;
		    	case P29:
		    		CLEARLIGHTS29.add(light);
		    		break;
		    	case P30:
		    		CLEARLIGHTS30.add(light);
		    		break;
		    	case P31:
		    		CLEARLIGHTS31.add(light);
		    		break;
		    	case P32:
		    		CLEARLIGHTS32.add(light);
		    		break;
		    	case P33:
		    		CLEARLIGHTS33.add(light);
		    		break;
		    	case P34:
		    		CLEARLIGHTS34.add(light);
		    		break;
		    	case P35:
		    		CLEARLIGHTS35.add(light);
		    		break;
		    	case P36:
		    		CLEARLIGHTS36.add(light);
		    		break;
		    	case P37:
		    		CLEARLIGHTS37.add(light);
		    		break;
		    	case P38:
		    		CLEARLIGHTS38.add(light);
		    		break;
		    	case P39:
		    		CLEARLIGHTS39.add(light);
		    		break;
		    	case P40:
		    		CLEARLIGHTS40.add(light);
		    		break;
		    	case P41:
		    		CLEARLIGHTS41.add(light);
		    		break;
		    	case P42:
		    		CLEARLIGHTS42.add(light);
		    		break;
		    	case P43:
		    		CLEARLIGHTS43.add(light);
		    		break;
		    	case P44:
		    		CLEARLIGHTS44.add(light);
		    		break;
		    	case P45:
		    		CLEARLIGHTS45.add(light);
		    		break;
		    	case P46:
		    		CLEARLIGHTS46.add(light);
		    		break;
		    	case P47:
		    		CLEARLIGHTS47.add(light);
		    		break;
		    	case P48:
		    		CLEARLIGHTS48.add(light);
		    		break;
		    	case P49:
		    		CLEARLIGHTS49.add(light);
		    		break;
		    	case P50:
		    		CLEARLIGHTS50.add(light);
		    		break;
		    		default:break;
		    	}
    	}
    }
}
